import { api } from '@/utils/request'
import type { 
  SchoolAdmin,
  SchoolAdminPageParams,
  SchoolAdminCreateRequest,
  PageResult,
  ApiResponse 
} from '@/types'

export class SchoolAdminService {
  /**
   * 分页查询学校管理员列表
   */
  static async getSchoolAdminPage(params: SchoolAdminPageParams): Promise<PageResult<SchoolAdmin>> {
    const response = await api.post<PageResult<SchoolAdmin>>('/circle/api-admin/sSchoolAdmin/page', params)
    return response.data
  }

  /**
   * 获取学校管理员详情
   */
  static async getSchoolAdminDetail(id: number): Promise<SchoolAdmin> {
    const response = await api.get<SchoolAdmin>(`/circle/api-admin/sSchoolAdmin/get/${id}`)
    return response.data
  }

  /**
   * 新增学校管理员
   */
  static async createSchoolAdmin(adminData: SchoolAdminCreateRequest): Promise<boolean> {
    const response = await api.post<boolean>('/circle/api-admin/sSchoolAdmin/create', adminData)
    return response.data
  }

  /**
   * 更新学校管理员
   */
  static async updateSchoolAdmin(adminData: Partial<SchoolAdmin>): Promise<boolean> {
    const response = await api.post<boolean>('/circle/api-admin/sSchoolAdmin/update', adminData)
    return response.data
  }

  /**
   * 删除学校管理员
   */
  static async deleteSchoolAdmin(id: number): Promise<boolean> {
    const response = await api.delete<boolean>(`/circle/api-admin/sSchoolAdmin/delete/${id}`)
    return response.data
  }
}

// 默认导出单例实例
export const schoolAdminService = SchoolAdminService 